package com.prs.crm.action.cqunicom;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;

import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.cqunicom.PoplarOrder;
import com.prs.crm.domain.hr.Person;
import com.prs.crm.service.cqunicom.OrderService;
import com.prs.crm.service.hr.PersonService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-3-22 下午05:36:18
 * 简单说明
 */

public class GoogleMapAction extends BaseAction {
	
	private static final long serialVersionUID = 1L;
	
	private String rootName;
	
	private PoplarOrder order;

	private OrderService orderService;
	
	private Person person;
	
	private PersonService personService;

	@Action("lookGoogleMap")
	public String lookGoogleMap() {
		return SUCCESS;
	}
	@Action("dataDevlution")
	public String dataDevlution(){
		return SUCCESS;
	}
/**
 * 数据移交处理
 * @return
 */
	@Clew(results = { "success", "none" })
	@Action(value = "saveDataVeryt", results = {
			@Result(name = "success", type = "redirect", location = "dataDevlution"),
			@Result(name = "none", type = "redirect", location = "dataDevlution"),
			@Result(name = "error", type = "chain", location = "dataDevlution") })
	public String saveDataVeryt() {
		
		
		if(rootName==""){
			this.setPrompt("数据移交处理失败....");
			return SUCCESS;
		}else{
			Person po=this.getPersonService().getByroot(rootName);
			if(po==null){
				this.setPrompt("数据移交处理失败....");
				return SUCCESS;
			}else{
			Person currentPo=AppContext.getAccountContext().getUser();
			List<PoplarOrder>  orderList=this.getOrderService().getByPerson(currentPo);
			for(PoplarOrder op:orderList){
				op.setPerson(po);
				this.getPersonService().submit(po);
				
			}
				this.setPrompt("数据移交处理成功....");
				return SUCCESS;
			}
		}
		
		
		
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getRootName() {
		return rootName;
	}
	public void setRootName(String rootName) {
		this.rootName = rootName;
	}
	public PoplarOrder getOrder() {
		return order;
	}
	public void setOrder(PoplarOrder order) {
		this.order = order;
	}
	public OrderService getOrderService() {
		return orderService;
	}
	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}
	public Person getPerson() {
		return person;
	}
	public void setPerson(Person person) {
		this.person = person;
	}
	public PersonService getPersonService() {
		return personService;
	}
	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}


}
